let getNowDate = () => {
  var date = new Date();
  var seperator1 = "-";
  var month = date.getMonth() + 1;
  var day = date.getDate();
  if (month >= 1 && month <= 9) {
      month = "0" + month;
  }
  if (day >= 0 && day <= 9) {
      day = "0" + day;
  }
  var currentdate = date.getFullYear() + seperator1 + month + seperator1 + day
  return currentdate;
}
let startTimestamp = 0
let endTimestamp = 0
import $service from '../../../../service'
Page({
  data: {
    isShowDialog: false,
    array: ['检查', '检验'],
    index: 1,
    startTime: '开始时间',
    endTime: '结束时间',
    startData: '2020-01-01',
    endData: getNowDate()
  },
  onLoad: function (options) {

  },
  onShow: function () {

  },

  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  },
  showDialog() {
    this.data.isShowDialog = !this.data.isShowDialog
    this.setData({
      isShowDialog: this.data.isShowDialog
    })
  },
  selectUser() {
    console.log('11')
  },
  toDetail() {
    $service.openPage(`../personal_report_detail/personal_report_detail`)
  },
  bindPickerTime(e) {
    let {value} = e.detail
    let {type} = e.currentTarget.dataset
    type == 'start' ?  startTimestamp = $service.timeFormat(value) : endTimestamp = $service.timeFormat(value) 
    if (startTimestamp && endTimestamp && endTimestamp <= startTimestamp) {
      $service.showToast('结束时间必须大于开始时间！')
      type == 'start' ?  startTimestamp = 0 : endTimestamp = 0
      return
    }
    if (type == 'start') {
        this.setData({
          startTime: value
        })
    } else {
      this.setData({
        endTime: value
      })
    }
  }

})